import request from '../utils/request';

export const fetchDataCustom = customParam => {
    return request(customParam);
};

export const fetchDataPost = query => {
    return request({
        url: query.url,
        method: 'post',
        data: query.data
    });
};

export const getResidentCount = query => {
    return request({
        url: '/residentcenter/resident/getResidentCount',
        method: 'post',
        data: query.data
    });
};

export const fetchDataGet = query => {
    let url = query.url.replace("{id}", query.id);
    return request({
        url: url,
        method: 'get',
        params: query.data
    });
};

export const getStreet = query => {
    let url = query.url.replace("{id}", query.id);
    return request({
        url: url,
        method: 'get',
        params: query.data
    });
};

export const getCommunity = query => {
    query.url='/usercenter/community/community/'+query.id;
    return request({
        url: query.url,
        method: 'get'
    });
};

export const certificationPost = query => {
    return request({
        url: '/residentcenter/resident/update/resident/status',
        method: 'post',
        data: query.data
    });
};


export const addResident = query => {
    return request({
        url: query.url,
        method: 'post',
        data: query.data
    });
};
export const download = query => {
    return request({
        url: '/residentcenter/resident/downloadExcel',
        method: 'post',
        responseType: 'blob'
    });
};

export const editResident = query => {
    let url = query.url.replace("{id}", query.id);
    if (query.isParamData) {
        return request({
            url: url,
            method: 'post',
            params: query.data
        });
    } else {
        return request({
            url: url,
            method: 'post',
            data: query.data
        });
    }
};

export const fetchDataDel = query => {
    let url = query.url.replace("{id}", query.id);
    return request({
        url: url,
        method: 'delete',
        data: query.data
    });
};

export const getPermission = query => {
    return request({
        url: query.url,
        method: 'get',
        params: query.data
    });
};

export function getUserDetail(data) {
    let url = '/usercenter/user/{id}';
    return request({
        url: url.replace("{id}", data.id),
        method: 'get'
    })
}

export function exportExc(data) {
    let url = '/residentcenter/resident/exportResident';
    return request({
        url: url,
        method: 'post',
        data: data,
        responseType: 'blob'
    })
}
